package vue;

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import controleur.DeplacementZoom;

import model.Environnement;
import model.ThreadEnvironnement;

public class Fenetre extends JFrame {
	private PanneauPrincipal panPrinc;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public Fenetre(Environnement env, ThreadEnvironnement t) {
		setTitle("Jeu de la vie");
		setSize(700, 300);
		panPrinc = new PanneauPrincipal(env, t);
		setJMenuBar(new Menu(env, t, panPrinc));
		this.addKeyListener(new DeplacementZoom(panPrinc, env));
		this.setFocusable(true);
		this.requestFocus();
		getContentPane().add(panPrinc, BorderLayout.CENTER);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent we) {
				System.exit(0);
			}
		});
	}

	static public void main(String arg[]) {
		Environnement env = new Environnement(10, 10);
		ThreadEnvironnement t = new ThreadEnvironnement(env);
		Fenetre fen = new Fenetre(env, t);
		fen.setVisible(true);
		t.start();
	}
}
